<?php
/**
 * 系统日志--单例
 */
class Slog {
	protected $logDao;
	protected static $_instance;

	function __construct() {
		$this->logDao = M('Log');
	}

	private function __clone() {
	}

	public static function getInstance() {
		if (self::$_instance == null) {
			self::$_instance = new self ();
		}
		return self::$_instance;
	}

	public function write($option,$msg=array()) {
		$usern = $_SESSION['uname'];
		if(!empty($usern ) && !empty($option)){
			$msg['action']=ACTION_NAME;
			$msg['module']=MODULE_NAME;
			$data = array(
				'user'=>$usern,
				'code'=>$option,
				'msg'=>json_encode($msg),
				'ip'=>get_client_ip(),
				'row_date'=>time(),
			);
			$this->logDao->add($data);
		}
	}
}
?>